import consts from "../../js/const";
import util from "../../utils/util";
import {routerFilter} from '../../utils/routerFilter';
routerFilter({

  /**
   * 页面的初始数据
   */
  data: {
    option1: [
      { text: '功能', value: '功能' }
    ],
    option2: [
      {text:'车型',value:'车型'}
    ],
    option3: [
      {text:'故障',value:'故障'}
    ],
    value1:'功能',
    value2:'车型',
    value3:'故障'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    that.isLogin(null,function () {
      util.promise('/baseConfig/searchPageConfigByTypeCde', {isRequestParam:true,pageCde:'vehicleRepair',typeCde:'CAROUSEL',status:'FILE'}).then(function (res) {
        if (res.data) {
          that.setData({carousels:res.data});
        }
      });
    });
    util.promise('/baseConfig/searchEycVehicleMaintQa').then(function (res) {
      if (res.data) {
        that.setData({vehicleMaintQas:res.data});
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  showAnswer:function (event) {
    let vehicleMaintQa = event.currentTarget.dataset.item;
    wx.navigateTo({
      url: '/pages/vehicle/answer',
      success: function (res) {
        // 通过eventChannel向被打开页面传送数据
          res.eventChannel.emit('acceptDataFromOpenerPage', {vehicleMaintQa:vehicleMaintQa});
      }
    })
  }
});